# -*- coding:utf-8 -*-
# Created by Jin(jinzhencheng@outlook.com) at 2018/8/28 18:17

from bd_spider.util import db_helper
from bd_spider.util import logger
from bd_spider.entity import Category

__mysql_helper = db_helper.MySQLHelper("bd_article_sys")
__the_logger = logger.get_logger()


def list_category():
    category_list = list()
    try:
        __mysql_helper.open_driver()
        session = __mysql_helper.session
        category_list = session.query(Category).all()
    except Exception, e:
        __the_logger.error("An exception happened when query all items from database, details: %s" % e.message)
    return category_list
